home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
progjour
/
1991
/
06
/
alib
/
perror.asm
< prev
next >
Wrap
Assembly Source File
|
1990-05-01
|
972b
|
51 lines
title perror - print error message
include asm.inc
public perror
.data
extrn dgroup_segment:word
.data?
errmsg_buffer db 100 dup(?)
.code
extn clear_strerror,get_strerror,fwrite,save_most,strcpy_limit
;; perror
;
; entry DS:SI optional message prefix
; uses AX
;
perror proc
call save_most
mov es,dgroup_segment[bp] ; set destination pointer
mov di,offset errmsg_buffer
lea dx,[di+size errmsg_buffer-4] ; (-4 leaves room for ": " & \n)
cmp si,NULL_POINTER
je per1 ; if no message prefix
call strcpy_limit ; else copy message prefix
mov ax,' :' ; and ": "
stosw
per1: call get_strerror
jz per2 ; if no error string
call clear_strerror
call strcpy_limit
per2: mov ax,NEWLINE_CHARS ; append \n
stosw
mov bx,stderr ; write text to standard error
mov ds,dgroup_segment[bp]
lea si,errmsg_buffer
mov cx,di ; compute message byte count
sub cx,si
call fwrite
ret
perror endp
end